package com.base.monitor.module.biz.server;

import com.base.monitor.module.biz.util.ConvertUtils;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToMessageDecoder;

import java.util.List;

public class HexDecoder extends ByteToMessageDecoder {

    @Override
    protected void decode(ChannelHandlerContext ctx, ByteBuf buffer, List<Object> out) throws Exception {
        byte[] content = new byte[buffer.readableBytes()];
        buffer.readBytes(content);
        out.add(ConvertUtils.bytesToHexString(content));
    }
}
